﻿using Modules.Project;
using Modules.System.Attachment;
using PmSoft.Quartz;
using Quartz;

namespace ManagementApi.Jobs;


/// <summary>
/// 保证金账户超时失效
/// </summary>
[DisallowConcurrentExecution]//不可并行执行
[JobDescription("0 0 00 * * ?")]//必须每天0点执行
public class CheckExpireGuaranteePaymentJob : IJob
{
    private readonly ProjectGuaranteePaymentService paymentService;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="paymentService"></param>
    public CheckExpireGuaranteePaymentJob(ProjectGuaranteePaymentService paymentService)
    {
        this.paymentService = paymentService;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="context"></param>
    /// <returns></returns>
    public Task Execute(IJobExecutionContext context)
    {
        //将终止时间大于当前时间的缴纳信息设为失效
        paymentService.MarkPaymentExpire();
        return Task.CompletedTask;
    }
}
